from socket import socket, AF_INET, SOCK_STREAM

# 1.创建scoket对象
socket_server = socket(AF_INET, SOCK_STREAM)

# 绑定地址
ip = '127.0.0.1'
port = 8899
socket_server.bind((ip, port))

# TCP监听,最大数为5， 默认为5
socket_server.listen(5)
print('server start ...')

# 接收客户端信息 , accept等待客户端连接，如果没有连接不会往下执行
conn, addr = socket_server.accept()
info =''
while info != 'bye' :
    info = conn.recv(1024)
    t = info.decode('utf-8')
    print('接收的信息是：',t )

    if t == 'bye':
        break

    data = input("请输入回复信息：")
    conn.send(data.encode('utf-8'))

conn.close()
socket_server.close()

